import http from '@/api/http.js'; 
import config from '@/config.js'; 

export default {
	// 通用接口
	common: {
		// 通用接口
		get_objects(type) {
			return http.request('GET', `${config.closet_url}/comm/${type}/`);
		},
		get_object(type, id) {
			return http.request('GET', `${config.closet_url}/comm/${type}/${id}/`);
		},
		create_object(type, data) {
			return http.request('POST', `${config.closet_url}/comm/${type}/`, data);
		},
		update_object(type, id, data) {
			return http.request('PUT', `${config.closet_url}/comm/${type}/${id}/`, data);
		},
		update_object_partial(type, id, data) {
			return http.request('PATCH', `${config.closet_url}/comm/${type}/${id}/`, data);
		},	
		delete_object(type, id) {
			return http.request('DELETE', `${config.closet_url}/comm/${type}/${id}/`);
		},
		update_main_image(type, id, name, base64_content) {
			let data = {
				file_name: name,
				base64_content: base64_content,
			}
			return http.request('POST', `${config.closet_url}/comm/${type}/${id}/update_main_image/`, data);
			// return http.request_file(`${config.closet_url}/comm/${type}/${id}/update_main_image/`, file.url);
		},
	},
	get_categories_info() {
		return http.request('GET', `${config.closet_url}/get_categories_info/`);
	},
	get_categories_list() {
		return http.request('GET', `${config.closet_url}/get_categories_list/`);
	},
	get_clothes_by_subcat(data) {
		return http.request('GET', `${config.closet_url}/get_clothes_by_subcat/`, data);
	},
	get_clothes_by_cat(data) {
		return http.request('GET', `${config.closet_url}/get_clothes_by_cat/`, data);
	},
	get_size_list() {
		return http.request('GET', `${config.closet_url}/get_size_list/`);
	},
	get_tag_list() {
		return http.request('GET', `${config.closet_url}/get_tag_list/`);
	},
	get_day_record(data) {
		return http.request('GET', `${config.closet_url}/get_day_record/`, data);
	},
	get_month_record(data) {
		return http.request('GET', `${config.closet_url}/get_month_record/`, data);
	},
};